<?php
declare(strict_types=1);
/**
 * Created by PhpStorm
 * User: Administrator
 * Date: 2023/4/10
 * Time: 14:47:37
 */
namespace App\Controller\Cash\v1;

use App\Controller\AbstractController;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\Middleware;
use App\Middleware\CashMiddleware;
use Hyperf\HttpServer\Annotation\RequestMapping;
use Hyperf\HttpServer\Contract\RequestInterface;
use Service\StoreService\StoreService;
use Service\UserService\CashManagerService;

/**
 * 店铺
 * @Controller(prefix="/cash/v1/store")
 * @Middleware(CashMiddleware::class)
 */

class StoreController extends AbstractController
{
    /**
     * @Inject()
     * @var StoreService
     */
    protected $storeService;

    /**
     *交班接口
     * @RequestMapping(path="cashcheck",methods="post")
     * @param RequestInterface $request
     * @return mixed
     */
    public function cashcheck(RequestInterface $request)
    {
        $param = $request->all();
        $param['mn_sid'] = $request->getAttribute('mn_sid');
        $param['cid'] = $request->getAttribute('cid');
        $param['casher_id'] = $request->getAttribute('casher_id');
        $param['manager_id'] = $request->getAttribute('manager_id');
        return $this->storeService->cashcheck($param);
    }

    /**
     *获取当前用户营业额 （交班前统计）
     * @RequestMapping(path="cashcheckdata",methods="post")
     * @param RequestInterface $request
     * @return array
     */
    public function cashcheckdata(RequestInterface $request)
    {
        $param = $request->all();
        $param['mn_sid'] = $request->getAttribute('mn_sid');
        $param['cid'] = $request->getAttribute('cid');
        $param['casher_id'] = $request->getAttribute('casher_id');
        $param['manager_id'] = $request->getAttribute('manager_id');
        return $this->storeService->cashcheckdata($param);
    }
    
    /**
     * 收银员验证改价密码
     * @RequestMapping(path="checkmodifypricepasswd", methods="POST")
     * @return string[]
     */
    public function checkCashModifyPricePasswd( RequestInterface $request, CashManagerService $cashManagerService ) 
    {
        
        return $cashManagerService->checkCashModifyPricePasswd($request->getAttribute('mn_sid'),$request->getParsedBody());
    }

    /**
     * 当班销售明细
     * @RequestMapping(path="cashSaleDetail",methods="POST")
     */
    public function cashSaleDetail(RequestInterface $request){
        $param = $request->all();
        $param['mn_sid'] = $request->getAttribute('mn_sid');
        $param['cid'] = $request->getAttribute('cid');
        $param['casher_id'] = $request->getAttribute('casher_id');
        $param['manager_id'] = $request->getAttribute('manager_id');
        return $this->storeService->cashSaleDetail($param);
    }
    
}
